#{extends 'CRUD/layout.html' /}
#{set title:messages.get('crud.list.title', type.name) /}

<div id="crudList" class="${type.name}">

    <h2 id="crudListTitle">&{'crud.list.title', type.name}</h2>

    <div id="crudListSearch">
    #{crud.search /}
    </div>

    <div id="crudListTable">
    #{crud.table fields:['event', 'documentType','code','Nombre', 'Correo', 'profile', 'Activo','Tareas']}
        #{crud.custom 'documentType'}
        ${object.personDocument.documentType}
        #{/crud.custom}
        #{crud.custom 'code'}
        ${object.personDocument.code}
        #{/crud.custom}
        #{crud.custom 'event'}
        ${object.event}
        #{/crud.custom}
        #{crud.custom 'Nombre'}
        ${object.personDocument.person}
        #{/crud.custom}
        #{crud.custom 'Correo'}
        ${object.personDocument.person.email}
        #{/crud.custom}
        #{crud.custom 'profile'}
        &{object.profile}
        #{/crud.custom}

        #{crud.custom 'Activo'}
            <input id="${object.id}check" type="checkbox"
                   onclick="changeIncriptionStatus(${object.id})" ${object.isActive ==true  ? 'checked':'' } >
        #{/crud.custom}
        #{crud.custom 'Tareas'}
            <a href="@{Inscriptions.show(object.id)}">Ver / Editar</a>
        #{/crud.custom}
    #{/crud.table}
    </div>

    <div id="crudListPagination">
    #{crud.pagination /}
    </div>

    <p id="crudListAdd">
        <a href="@{blank()}">&{'crud.add', type.modelName}</a>
    </p>

</div>
<script>
    function changeIncriptionStatus(id) {
        //put token request
        var checked = $('#' + id + 'check').is(':checked');
        var url = "@{changeIncriptionStatus}";

        $.post(url, { "id":id, "checked":checked},
                function (data) {
                    showStatus(true,data.message);
                }, "json")
                .error(function () {
                    showStatus(false,"505");
                });
    }
</script>
